/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __A_EXC_H__
#define __A_EXC_H__

/* includes (standard library, system) ---------------------------------------*/
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
#include <kconfig.h>
/* includes (local) ----------------------------------------------------------*/
#include "a_regset.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* defines -------------------------------------------------------------------*/

#define EXC_VEC_RESET        1
#define EXC_VEC_NMI          2
#define EXC_VEC_HARDFAULT    3
#define EXC_VEC_MEMMANAGE    4
#define EXC_VEC_BUSFAULT     5
#define EXC_VEC_USABEFAULT   6
#define EXC_VEC_SVC          11
#define EXC_VEC_DEBUGMONITOR 12
#define EXC_VEC_PENDSV       14
#define EXC_VEC_SYSTICK      15

/* typedefs ------------------------------------------------------------------*/

typedef struct exc_info {
    struct esp *esp;
    uint32_t r4;
    uint32_t r5;
    uint32_t r6;
    uint32_t r7;
    uint32_t r8;
    uint32_t r9;
    uint32_t r10;
    uint32_t r11;
    uint32_t exclr;
#ifdef CONFIG_CORTEX_M_MAINLINE
    uint32_t shcsr;
    uint32_t cfsr;
    uint32_t hfsr;
    uint32_t dfsr;
    uint32_t mmfar;
    uint32_t bfar;
#endif
} exc_info_t;

/* macro ---------------------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* externs -------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __A_EXC_H__ */
